<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="sealte.hvpms.pojo.*,sealte.hvpms.dao.impl.RulesDAOImpl,java.util.List,java.util.Iterator" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>网上投票管理系统</title>
<link type="text/css" rel="stylesheet" href="css/vp_add.jsp.css" />
<script src="js/jquery-1.4.4.min.js" type="text/javascript"></script>
<script src="util/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
<script src="js/vp.add.step1.js" type="text/javascript"></script>
</head>
<body>
<%
	UserCreate uc = (UserCreate)session.getAttribute("UserCreate");
	if(uc!=null){
		Poll poll = (Poll)session.getAttribute("vp_add1");
%>
<div id="num2">
	<h2><img src="images/page.png">&nbsp;投票信息管理--新增&nbsp;&nbsp;[1/2]&nbsp;&nbsp;投票信息</h2>
</div>
<div id="num1">
<form action="home/vp_add2.jsp" method="POST" id="firstStep">
<table>
	<tr onmouseover=sbar(this) onmouseout=cbar(this)>
		<th>标题</th>
		<td>
		<input type="text" name="vp_title" id="vpTitle" size="40" value="<%=(poll!=null)?(poll.getName()):"" %>" onblur="ajaxValidateExist(<%=uc.getId() %>)">
		<span id="span_vpTitle"></span>
		</td>
	</tr>
	<tr onmouseover=sbar(this) onmouseout=cbar(this)>
		<th>描述</th>
		<td>
		<textarea cols="40" rows="3" name="vp_descriptions" id="vpDescriptions"><%=(poll!=null)?(poll.getDescriptions()):"" %></textarea>
		<span id="span_vpDescriptions"></span>
		</td>
	</tr>
	<tr onmouseover=sbar(this) onmouseout=cbar(this)>
		<th>选项数</th>
		<td>
		<input type="text" size="4" name="vp_options" id="vpOptions" value="<%=(poll!=null)?(poll.getOptions()):"" %>"/>
		<span id="span_vpOptions"></span>
		</td>
	</tr>
	<tr onmouseover=sbar(this) onmouseout=cbar(this)>
		<th>最多可选项数</th>
		<td align="left">
		<input type="text" size="4" name="vp_maxanswers" id="vpMaxanswers" value="<%=(poll!=null)?(poll.getMaxanswers()):"" %>"/>
		<span id="span_vpMaxanswers"></span>
		</td>
	</tr>
	<tr onmouseover=sbar(this) onmouseout=cbar(this)>
		<th>到期日期</th>
		<td>
		<input class="Wdate" type="text" name="vp_enddate" id="vpEnddate" onclick="WdatePicker()" value="<%=(poll!=null)?(poll.getEnddate()):"" %>"/>
		<span id="span_vpEnddate"></span>
		</td>
	</tr>
	<tr onmouseover=sbar(this) onmouseout=cbar(this)>
		<th>限制规则</th>
		<td>
		<select name="vp_rule" id="vpRule">
			<%
			RulesDAOImpl rb = new RulesDAOImpl();
			List<Rule> all = rb.getAll();
			if(all!=null){
				Iterator<Rule> iter = all.iterator();
				StringBuffer sb = new StringBuffer();
				sb.append("<option value=>--请选择限制规则--</option>");
				int i = 0;
				while(iter.hasNext()){
					Rule rule = iter.next();
					if(rule.getIsUsed().equals("Y")){
						if(((poll!=null)?(poll.getRule_int()):0)==rule.getId()){
							sb.append("<option value="+rule.getId()+" selected=selected>"+(++i)+"."+rule.getContent()+"</option>");
						}else{
							sb.append("<option value="+rule.getId()+">"+(++i)+"."+rule.getContent()+"</option>");
						}
					}
				}
				if(i==0){
					sb.append("<option value=>0.暂时没有限制规则</option>");
				}
				out.println(sb.toString());
			}else{
				out.println("<option value=>--暂时没有限制规则--</option>");
			}
			%>
		</select>
		<span id="span_vpRule"></span>
		</td>
	</tr>
	<tr>
		<td></td>
		<td>
		<input type="button" value="重置" onclick="clearAll()"/>
		<input type="button" value="下一步&gt;&gt;" onclick="firstStep()"/>
		</td>
	</tr>
</table>
</form>
</div>
<span id="message_addpoll">
	<%
		String message_addpoll = (String)request.getAttribute("message_addpoll");
		if(message_addpoll!=null&&!message_addpoll.equals("")){
			out.println("["+message_addpoll+"]");
		}
	%>
</span>
<%		
	}else{
		out.println("谢绝跨路径访问！");
	}
%>
</body>
</html>